import request from '@/utils/request'

export default {
    //显示所有订单
    selectAll(page, limit, state) {
        return request({
            url: `/CourseOrder/selectByState?page=${page}&limit=${limit}`,
            method: 'get'
        })
    },
    //根据状态分类订单
    selectByState(page, limit, state) {
        return request({
            url: `/CourseOrder/selectByState?state=${state}&page=${page}&limit=${limit}`,
            method: 'get'
        })
    },
    //根据条件搜索订单
    selectBykeyWord(page, limit, selectByAny) {
        return request({
            url: `/CourseOrder/selectBykeyWord/${page}/${limit}`,
            method: 'post',
            data: selectByAny
        })
    },
    //查看订单
    selectByID(id) {
        return request({
            url: `/CourseOrder/selectByID?id=${id}`,
            method: 'get'
        })
    },
    //删除订单，已关闭才能删除，根本不可见
    deleteOne(id) {
        return request({
            url: `/CourseOrder/deleteOne?id=${id}`,
            method: 'get'
        })
    },
    //结束课程，学习中才能结束，状态为已完成
    endCourse(id) {
        return request({
            url: `/CourseOrder/endCourse?id=${id}`,
            method: 'get'
        })
    },
    //取消订单，待付款、学习中才能取消，状态为已关闭
    cancelOrder(id) {
        return request({
            url: `/CourseOrder/cancelOrder?id=${id}`,
            method: 'get'
        })
    },
    //购买课程生成订单
    addOrder(courseOrder) {
        return request({
            url: `/CourseOrder/addOrder`,
            method: 'post',
            data: courseOrder
        })
    }
}